home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Modules / cstubs < prev    next >
Encoding:
Text File  |  2000-08-03  |  32.4 KB  |  1,364 lines

  1. /*
  2. Input used to generate the Python module "glmodule.c".
  3. The stub generator is a Python script called "cgen.py".
  4.  
  5. Each definition must be contained on one line:
  6.  
  7. <returntype> <name> <type> <arg> <type> <arg>
  8.  
  9. <returntype> can be: void, short, long (XXX maybe others?)
  10.  
  11. <type> can be: char, string, short, float, long, or double
  12.     string indicates a null terminated string;
  13.     if <type> is char and <arg> begins with a *, the * is stripped
  14.     and <type> is changed into string
  15.  
  16. <arg> has the form <mode> or <mode>[<subscript>]
  17.     where <mode> can be
  18.         s: arg is sent
  19.         r: arg is received        (arg is a pointer)
  20.     and <subscript> can be (N and I are numbers):
  21.         N
  22.         argI
  23.         retval
  24.         N*argI
  25.         N*I
  26.         N*retval
  27.     In the case where the subscript consists of two parts
  28.     separated by *, the first part is the width of the matrix, and
  29.     the second part is the length of the matrix.  This order is
  30.     opposite from the order used in C to declare a two-dimensional
  31.     matrix.
  32. */
  33.  
  34. /*
  35.  * An attempt has been made to make this module switch threads on qread
  36.  * calls. It is far from safe, though.
  37.  */
  38.  
  39. #include <gl.h>
  40. #include <device.h>
  41.  
  42. #ifdef __sgi
  43. extern int devport();
  44. extern int textwritemask();
  45. extern int pagewritemask();
  46. extern int gewrite();
  47. extern int gettp();
  48. #endif
  49.  
  50. #include "Python.h"
  51. #include "cgensupport.h"
  52.  
  53. /*
  54. Some stubs are too complicated for the stub generator.
  55. We can include manually written versions of them here.
  56. A line starting with '%' gives the name of the function so the stub
  57. generator can include it in the table of functions.
  58. */
  59.  
  60. % qread
  61.  
  62. static PyObject *
  63. gl_qread(self, args)
  64.     PyObject *self;
  65.     PyObject *args;
  66. {
  67.     long retval;
  68.     short arg1 ;
  69.     Py_BEGIN_ALLOW_THREADS
  70.     retval = qread( & arg1 );
  71.     Py_END_ALLOW_THREADS
  72.     { PyObject *v = PyTuple_New( 2 );
  73.       if (v == NULL) return NULL;
  74.       PyTuple_SetItem(v, 0, mknewlongobject(retval));
  75.       PyTuple_SetItem(v, 1, mknewshortobject(arg1));
  76.       return v;
  77.     }
  78. }
  79.  
  80.  
  81. /*
  82. varray -- an array of v.. calls.
  83. The argument is an array (maybe list or tuple) of points.
  84. Each point must be a tuple or list of coordinates (x, y, z).
  85. The points may be 2- or 3-dimensional but must all have the
  86. same dimension.  Float and int values may be mixed however.
  87. The points are always converted to 3D double precision points
  88. by assuming z=0.0 if necessary (as indicated in the man page),
  89. and for each point v3d() is called.
  90. */
  91.  
  92. % varray
  93.  
  94. static PyObject *
  95. gl_varray(self, args)
  96.     PyObject *self;
  97.     PyObject *args;
  98. {
  99.     PyObject *v, *w=NULL;
  100.     int i, n, width;
  101.     double vec[3];
  102.     PyObject * (*getitem) Py_FPROTO((PyObject *, int));
  103.     
  104.     if (!PyArg_GetObject(args, 1, 0, &v))
  105.         return NULL;
  106.     
  107.     if (PyList_Check(v)) {
  108.         n = PyList_Size(v);
  109.         getitem = PyList_GetItem;
  110.     }
  111.     else if (PyTuple_Check(v)) {
  112.         n = PyTuple_Size(v);
  113.         getitem = PyTuple_GetItem;
  114.     }
  115.     else {
  116.         PyErr_BadArgument();
  117.         return NULL;
  118.     }
  119.     
  120.     if (n == 0) {
  121.         Py_INCREF(Py_None);
  122.         return Py_None;
  123.     }
  124.     if (n > 0)
  125.         w = (*getitem)(v, 0);
  126.     
  127.     width = 0;
  128.     if (w == NULL) {
  129.     }
  130.     else if (PyList_Check(w)) {
  131.         width = PyList_Size(w);
  132.     }
  133.     else if (PyTuple_Check(w)) {
  134.         width = PyTuple_Size(w);
  135.     }
  136.     
  137.     switch (width) {
  138.     case 2:
  139.         vec[2] = 0.0;
  140.         /* Fall through */
  141.     case 3:
  142.         break;
  143.     default:
  144.         PyErr_BadArgument();
  145.         return NULL;
  146.     }
  147.     
  148.     for (i = 0; i < n; i++) {
  149.         w = (*getitem)(v, i);
  150.         if (!PyArg_GetDoubleArray(w, 1, 0, width, vec))
  151.             return NULL;
  152.         v3d(vec);
  153.     }
  154.     
  155.     Py_INCREF(Py_None);
  156.     return Py_None;
  157. }
  158.  
  159. /*
  160. vnarray, nvarray -- an array of n3f and v3f calls.
  161. The argument is an array (list or tuple) of pairs of points and normals.
  162. Each pair is a tuple (NOT a list) of a point and a normal for that point.
  163. Each point or normal must be a tuple (NOT a list) of coordinates (x, y, z).
  164. Three coordinates must be given.  Float and int values may be mixed.
  165. For each pair, n3f() is called for the normal, and then v3f() is called
  166. for the vector.
  167.  
  168. vnarray and nvarray differ only in the order of the vector and normal in
  169. the pair: vnarray expects (v, n) while nvarray expects (n, v).
  170. */
  171.  
  172. static PyObject *gen_nvarray(); /* Forward */
  173.  
  174. % nvarray
  175.  
  176. static PyObject *
  177. gl_nvarray(self, args)
  178.     PyObject *self;
  179.     PyObject *args;
  180. {
  181.     return gen_nvarray(args, 0);
  182. }
  183.  
  184. % vnarray
  185.  
  186. static PyObject *
  187. gl_vnarray(self, args)
  188.     PyObject *self;
  189.     PyObject *args;
  190. {
  191.     return gen_nvarray(args, 1);
  192. }
  193.  
  194. /* Generic, internal version of {nv,nv}array: inorm indicates the
  195.    argument order, 0: normal first, 1: vector first. */
  196.  
  197. static PyObject *
  198. gen_nvarray(args, inorm)
  199.     PyObject *args;
  200.     int inorm;
  201. {
  202.     PyObject *v, *w, *wnorm, *wvec;
  203.     int i, n;
  204.     float norm[3], vec[3];
  205.     PyObject * (*getitem) Py_FPROTO((PyObject *, int));
  206.     
  207.     if (!PyArg_GetObject(args, 1, 0, &v))
  208.         return NULL;
  209.     
  210.     if (PyList_Check(v)) {
  211.         n = PyList_Size(v);
  212.         getitem = PyList_GetItem;
  213.     }
  214.     else if (PyTuple_Check(v)) {
  215.         n = PyTuple_Size(v);
  216.         getitem = PyTuple_GetItem;
  217.     }
  218.     else {
  219.         PyErr_BadArgument();
  220.         return NULL;
  221.     }
  222.     
  223.     for (i = 0; i < n; i++) {
  224.         w = (*getitem)(v, i);
  225.         if (!PyTuple_Check(w) || PyTuple_Size(w) != 2) {
  226.             PyErr_BadArgument();
  227.             return NULL;
  228.         }
  229.         wnorm = PyTuple_GetItem(w, inorm);
  230.         wvec = PyTuple_GetItem(w, 1 - inorm);
  231.         if (!PyArg_GetFloatArray(wnorm, 1, 0, 3, norm) ||
  232.             !PyArg_GetFloatArray(wvec, 1, 0, 3, vec))
  233.             return NULL;
  234.         n3f(norm);
  235.         v3f(vec);
  236.     }
  237.     
  238.     Py_INCREF(Py_None);
  239.     return Py_None;
  240. }
  241.  
  242. /* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type).
  243.    The dimensions of ctl[] are computed as follows:
  244.    [len(s_knots) - s_order], [len(t_knots) - t_order]
  245. */
  246.  
  247. % nurbssurface
  248.  
  249. static PyObject *
  250. gl_nurbssurface(self, args)
  251.     PyObject *self;
  252.     PyObject *args;
  253. {
  254.     long arg1 ;
  255.     double * arg2 ;
  256.     long arg3 ;
  257.     double * arg4 ;
  258.     double *arg5 ;
  259.     long arg6 ;
  260.     long arg7 ;
  261.     long arg8 ;
  262.     long ncoords;
  263.     long s_byte_stride, t_byte_stride;
  264.     long s_nctl, t_nctl;
  265.     long s, t;
  266.     PyObject *v, *w, *pt;
  267.     double *pnext;
  268.     if (!PyArg_GetLongArraySize(args, 6, 0, &arg1))
  269.         return NULL;
  270.     if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) {
  271.         return PyErr_NoMemory();
  272.     }
  273.     if (!PyArg_GetDoubleArray(args, 6, 0, arg1 , arg2))
  274.         return NULL;
  275.     if (!PyArg_GetLongArraySize(args, 6, 1, &arg3))
  276.         return NULL;
  277.     if ((arg4 = PyMem_NEW(double, arg3 )) == NULL) {
  278.         return PyErr_NoMemory();
  279.     }
  280.     if (!PyArg_GetDoubleArray(args, 6, 1, arg3 , arg4))
  281.         return NULL;
  282.     if (!PyArg_GetLong(args, 6, 3, &arg6))
  283.         return NULL;
  284.     if (!PyArg_GetLong(args, 6, 4, &arg7))
  285.         return NULL;
  286.     if (!PyArg_GetLong(args, 6, 5, &arg8))
  287.         return NULL;
  288.     if (arg8 == N_XYZ)
  289.         ncoords = 3;
  290.     else if (arg8 == N_XYZW)
  291.         ncoords = 4;
  292.     else {
  293.         PyErr_BadArgument();
  294.         return NULL;
  295.     }
  296.     s_nctl = arg1 - arg6;
  297.     t_nctl = arg3 - arg7;
  298.     if (!PyArg_GetObject(args, 6, 2, &v))
  299.         return NULL;
  300.     if (!PyList_Check(v) || PyList_Size(v) != s_nctl) {
  301.         PyErr_BadArgument();
  302.         return NULL;
  303.     }
  304.     if ((arg5 = PyMem_NEW(double, s_nctl*t_nctl*ncoords )) == NULL) {
  305.         return PyErr_NoMemory();
  306.     }
  307.     pnext = arg5;
  308.     for (s = 0; s < s_nctl; s++) {
  309.         w = PyList_GetItem(v, s);
  310.         if (w == NULL || !PyList_Check(w) ||
  311.                     PyList_Size(w) != t_nctl) {
  312.             PyErr_BadArgument();
  313.             return NULL;
  314.         }
  315.         for (t = 0; t < t_nctl; t++) {
  316.             pt = PyList_GetItem(w, t);
  317.             if (!PyArg_GetDoubleArray(pt, 1, 0, ncoords, pnext))
  318.                 return NULL;
  319.             pnext += ncoords;
  320.         }
  321.     }
  322.     s_byte_stride = sizeof(double) * ncoords;
  323.     t_byte_stride = s_byte_stride * s_nctl;
  324.     nurbssurface( arg1 , arg2 , arg3 , arg4 ,
  325.         s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 );
  326.     PyMem_DEL(arg2);
  327.     PyMem_DEL(arg4);
  328.     PyMem_DEL(arg5);
  329.     Py_INCREF(Py_None);
  330.     return Py_None;
  331. }
  332.  
  333. /* nurbscurve(knots, ctlpoints, order, type).
  334.    The length of ctlpoints is len(knots)-order. */
  335.  
  336. %nurbscurve
  337.  
  338. static PyObject *
  339. gl_nurbscurve(self, args)
  340.     PyObject *self;
  341.     PyObject *args;
  342. {
  343.     long arg1 ;
  344.     double * arg2 ;
  345.     long arg3 ;
  346.     double * arg4 ;
  347.     long arg5 ;
  348.     long arg6 ;
  349.     int ncoords, npoints;
  350.     int i;
  351.     PyObject *v;
  352.     double *pnext;
  353.     if (!PyArg_GetLongArraySize(args, 4, 0, &arg1))
  354.         return NULL;
  355.     if ((arg2 = PyMem_NEW(double, arg1 )) == NULL) {
  356.         return PyErr_NoMemory();
  357.     }
  358.     if (!PyArg_GetDoubleArray(args, 4, 0, arg1 , arg2))
  359.         return NULL;
  360.     if (!PyArg_GetLong(args, 4, 2, &arg5))
  361.         return NULL;
  362.     if (!PyArg_GetLong(args, 4, 3, &arg6))
  363.         return NULL;
  364.     if (arg6 == N_ST)
  365.         ncoords = 2;
  366.     else if (arg6 == N_STW)
  367.         ncoords = 3;
  368.     else {
  369.         PyErr_BadArgument();
  370.         return NULL;
  371.     }
  372.     npoints = arg1 - arg5;
  373.     if (!PyArg_GetObject(args, 4, 1, &v))
  374.         return NULL;
  375.     if (!PyList_Check(v) || PyList_Size(v) != npoints) {
  376.         PyErr_BadArgument();
  377.         return NULL;
  378.     }
  379.     if ((arg4 = PyMem_NEW(double, npoints*ncoords )) == NULL) {
  380.         return PyErr_NoMemory();
  381.     }
  382.     pnext = arg4;
  383.     for (i = 0; i < npoints; i++) {
  384.         if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext))
  385.             return NULL;
  386.         pnext += ncoords;
  387.     }
  388.     arg3 = (sizeof(double)) * ncoords;
  389.     nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 );
  390.     PyMem_DEL(arg2);
  391.     PyMem_DEL(arg4);
  392.     Py_INCREF(Py_None);
  393.     return Py_None;
  394. }
  395.  
  396. /* pwlcurve(points, type).
  397.    Points is a list of points. Type must be N_ST. */
  398.  
  399. %pwlcurve
  400.  
  401. static PyObject *
  402. gl_pwlcurve(self, args)
  403.     PyObject *self;
  404.     PyObject *args;
  405. {
  406.     PyObject *v;
  407.     long type;
  408.     double *data, *pnext;
  409.     long npoints, ncoords;
  410.     int i;
  411.     if (!PyArg_GetObject(args, 2, 0, &v))
  412.         return NULL;
  413.     if (!PyArg_GetLong(args, 2, 1, &type))
  414.         return NULL;
  415.     if (!PyList_Check(v)) {
  416.         PyErr_BadArgument();
  417.         return NULL;
  418.     }
  419.     npoints = PyList_Size(v);
  420.     if (type == N_ST)
  421.         ncoords = 2;
  422.     else {
  423.         PyErr_BadArgument();
  424.         return NULL;
  425.     }
  426.     if ((data = PyMem_NEW(double, npoints*ncoords)) == NULL) {
  427.         return PyErr_NoMemory();
  428.     }
  429.     pnext = data;
  430.     for (i = 0; i < npoints; i++) {
  431.         if (!PyArg_GetDoubleArray(PyList_GetItem(v, i), 1, 0, ncoords, pnext))
  432.             return NULL;
  433.         pnext += ncoords;
  434.     }
  435.     pwlcurve(npoints, data, sizeof(double)*ncoords, type);
  436.     PyMem_DEL(data);
  437.     Py_INCREF(Py_None);
  438.     return Py_None;
  439. }
  440.  
  441.  
  442. /* Picking and Selecting */
  443.  
  444. static short *pickbuffer = NULL;
  445. static long pickbuffersize;
  446.  
  447. static PyObject *
  448. pick_select(args, func)
  449.     PyObject *args;
  450.     void (*func)();
  451. {
  452.     if (!PyArg_GetLong(args, 1, 0, &pickbuffersize))
  453.         return NULL;
  454.     if (pickbuffer != NULL) {
  455.         PyErr_SetString(PyExc_RuntimeError,
  456.             "pick/gselect: already picking/selecting");
  457.         return NULL;
  458.     }
  459.     if ((pickbuffer = PyMem_NEW(short, pickbuffersize)) == NULL) {
  460.         return PyErr_NoMemory();
  461.     }
  462.     (*func)(pickbuffer, pickbuffersize);
  463.     Py_INCREF(Py_None);
  464.     return Py_None;
  465. }
  466.  
  467. static PyObject *
  468. endpick_select(args, func)
  469.     PyObject *args;
  470.     long (*func)();
  471. {
  472.     PyObject *v, *w;
  473.     int i, nhits, n;
  474.     if (!PyArg_NoArgs(args))
  475.         return NULL;
  476.     if (pickbuffer == NULL) {
  477.         PyErr_SetString(PyExc_RuntimeError,
  478.             "endpick/endselect: not in pick/select mode");
  479.         return NULL;
  480.     }
  481.     nhits = (*func)(pickbuffer);
  482.     if (nhits < 0) {
  483.         nhits = -nhits; /* How to report buffer overflow otherwise? */
  484.     }
  485.     /* Scan the buffer to see how many integers */
  486.     n = 0;
  487.     for (; nhits > 0; nhits--) {
  488.         n += 1 + pickbuffer[n];
  489.     }
  490.     v = PyList_New(n);
  491.     if (v == NULL)
  492.         return NULL;
  493.     /* XXX Could do it nicer and interpret the data structure here,
  494.        returning a list of lists. But this can be done in Python... */
  495.     for (i = 0; i < n; i++) {
  496.         w = PyInt_FromLong((long)pickbuffer[i]);
  497.         if (w == NULL) {
  498.             Py_DECREF(v);
  499.             return NULL;
  500.         }
  501.         PyList_SetItem(v, i, w);
  502.     }
  503.     PyMem_DEL(pickbuffer);
  504.     pickbuffer = NULL;
  505.     return v;
  506. }
  507.  
  508. extern void pick(), gselect();
  509. extern long endpick(), endselect();
  510.  
  511. %pick
  512. static PyObject *gl_pick(self, args) PyObject *self, *args; {
  513.     return pick_select(args, pick);
  514. }
  515.  
  516. %endpick
  517. static PyObject *gl_endpick(self, args) PyObject *self, *args; {
  518.     return endpick_select(args, endpick);
  519. }
  520.  
  521. %gselect
  522. static PyObject *gl_gselect(self, args) PyObject *self, *args; {
  523.     return pick_select(args, gselect);
  524. }
  525.  
  526. %endselect
  527. static PyObject *gl_endselect(self, args) PyObject *self, *args; {
  528.     return endpick_select(args, endselect);
  529. }
  530.  
  531.  
  532. /* XXX The generator botches this one.  Here's a quick hack to fix it. */
  533.  
  534. /* XXX The generator botches this one.  Here's a quick hack to fix it. */
  535.  
  536. % getmatrix float r[16]
  537.  
  538. static PyObject *
  539. gl_getmatrix(self, args)
  540.     PyObject *self;
  541.     PyObject *args;
  542. {
  543.     Matrix arg1;
  544.     PyObject *v, *w;
  545.     int i, j;
  546.     getmatrix( arg1 );
  547.     v = PyList_New(16);
  548.     if (v == NULL) {
  549.         return PyErr_NoMemory();
  550.     }
  551.     for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) {
  552.         w = mknewfloatobject(arg1[i][j]);
  553.         if (w == NULL) {
  554.             Py_DECREF(v);
  555.             return NULL;
  556.         }
  557.         PyList_SetItem(v, i*4+j, w);
  558.     }
  559.     return v;
  560. }
  561.  
  562. /* Here's an alternate version that returns a 4x4 matrix instead of
  563.    a vector.  Unfortunately it is incompatible with loadmatrix and
  564.    multmatrix... */
  565.  
  566. % altgetmatrix float r[4][4]
  567.  
  568. static PyObject *
  569. gl_altgetmatrix(self, args)
  570.     PyObject *self;
  571.     PyObject *args;
  572. {
  573.     Matrix arg1;
  574.     PyObject *v, *w;
  575.     int i, j;
  576.     getmatrix( arg1 );
  577.     v = PyList_New(4);
  578.     if (v == NULL) {
  579.         return NULL;
  580.     }
  581.     for (i = 0; i < 4; i++) {
  582.         w = PyList_New(4);
  583.         if (w == NULL) {
  584.             Py_DECREF(v);
  585.             return NULL;
  586.         }
  587.         PyList_SetItem(v, i, w);
  588.     }
  589.     for (i = 0; i < 4; i++) {
  590.         for (j = 0; j < 4; j++) {
  591.             w = mknewfloatobject(arg1[i][j]);
  592.             if (w == NULL) {
  593.                 Py_DECREF(v);
  594.                 return NULL;
  595.             }
  596.             PyList_SetItem(PyList_GetItem(v, i), j, w);
  597.         }
  598.     }
  599.     return v;
  600. }
  601.  
  602. % lrectwrite
  603.  
  604. static PyObject *
  605. gl_lrectwrite(self, args)
  606.     PyObject *self;
  607.     PyObject *args;
  608. {
  609.     short x1 ;
  610.     short y1 ;
  611.     short x2 ;
  612.     short y2 ;
  613.     string parray ;
  614.     PyObject *s;
  615. #if 0
  616.     int pixcount;
  617. #endif
  618.     if (!PyArg_GetShort(args, 5, 0, &x1))
  619.         return NULL;
  620.     if (!PyArg_GetShort(args, 5, 1, &y1))
  621.         return NULL;
  622.     if (!PyArg_GetShort(args, 5, 2, &x2))
  623.         return NULL;
  624.     if (!PyArg_GetShort(args, 5, 3, &y2))
  625.         return NULL;
  626.     if (!PyArg_GetString(args, 5, 4, &parray))
  627.         return NULL;
  628.     if (!PyArg_GetObject(args, 5, 4, &s))
  629.         return NULL;
  630. #if 0
  631. /* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */
  632.     pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
  633.     if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) {
  634.         PyErr_SetString(PyExc_RuntimeError,
  635.                "string arg to lrectwrite has wrong size");
  636.         return NULL;
  637.     }
  638. #endif
  639.     lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray );
  640.     Py_INCREF(Py_None);
  641.     return Py_None;
  642. }
  643.  
  644. % lrectread
  645.  
  646. static PyObject *
  647. gl_lrectread(self, args)
  648.     PyObject *self;
  649.     PyObject *args;
  650. {
  651.     short x1 ;
  652.     short y1 ;
  653.     short x2 ;
  654.     short y2 ;
  655.     PyObject *parray;
  656.     int pixcount;
  657.     if (!PyArg_GetShort(args, 4, 0, &x1))
  658.         return NULL;
  659.     if (!PyArg_GetShort(args, 4, 1, &y1))
  660.         return NULL;
  661.     if (!PyArg_GetShort(args, 4, 2, &x2))
  662.         return NULL;
  663.     if (!PyArg_GetShort(args, 4, 3, &y2))
  664.         return NULL;
  665.     pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
  666.     parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
  667.     if (parray == NULL)
  668.         return NULL; /* No memory */
  669.     lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray));
  670.     return parray;
  671. }
  672.  
  673. % readdisplay
  674.  
  675. static PyObject *
  676. gl_readdisplay(self, args)
  677.     PyObject *self;
  678.         PyObject *args;
  679. {
  680.         short x1, y1, x2, y2;
  681.     unsigned long *parray, hints;
  682.     long size, size_ret;
  683.     PyObject *rv;
  684.  
  685.     if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
  686.       return 0;
  687.     size = (long)(x2+1-x1) * (long)(y2+1-y1);
  688.     rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long));
  689.     if ( rv == NULL )
  690.       return NULL;
  691.     parray = (unsigned long *)PyString_AsString(rv);
  692.     size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
  693.     if ( size_ret != size ) {
  694.         printf("gl_readdisplay: got %ld pixels, expected %ld\n",
  695.            size_ret, size);
  696.         PyErr_SetString(PyExc_RuntimeError, "readdisplay returned unexpected length");
  697.         return NULL;
  698.     }
  699.     return rv;
  700. }
  701.  
  702. /* Desperately needed, here are tools to compress and decompress
  703.    the data manipulated by lrectread/lrectwrite.
  704.  
  705.    gl.packrect(width, height, packfactor, bigdata) --> smalldata
  706.         makes 'bigdata' 4*(packfactor**2) times smaller by:
  707.         - turning it into B/W (a factor 4)
  708.         - replacing squares of size pacfactor by one
  709.           representative
  710.  
  711.    gl.unpackrect(width, height, packfactor, smalldata) --> bigdata
  712.         is the inverse; the numeric arguments must be *the same*.
  713.  
  714.    Both work best if width and height are multiples of packfactor
  715.    (in fact unpackrect will leave garbage bytes).
  716. */
  717.  
  718. % packrect
  719.  
  720. static PyObject *
  721. gl_packrect(self, args)
  722.     PyObject *self;
  723.     PyObject *args;
  724. {
  725.     long width, height, packfactor;
  726.     char *s;
  727.     PyObject *unpacked, *packed;
  728.     int pixcount, packedcount, x, y, r, g, b;
  729.     unsigned long pixel;
  730.     unsigned char *p;
  731.     unsigned long *parray;
  732.     if (!PyArg_GetLong(args, 4, 0, &width))
  733.         return NULL;
  734.     if (!PyArg_GetLong(args, 4, 1, &height))
  735.         return NULL;
  736.     if (!PyArg_GetLong(args, 4, 2, &packfactor))
  737.         return NULL;
  738.     if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */
  739.         return NULL;
  740.     if (!PyArg_GetObject(args, 4, 3, &unpacked))
  741.         return NULL;
  742.     if (width <= 0 || height <= 0 || packfactor <= 0) {
  743.         PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0");
  744.         return NULL;
  745.     }
  746.     pixcount = width*height;
  747.     packedcount = ((width+packfactor-1)/packfactor) *
  748.         ((height+packfactor-1)/packfactor);
  749.     if (PyString_Size(unpacked) != pixcount*sizeof(long)) {
  750.         PyErr_SetString(PyExc_RuntimeError,
  751.                "string arg to packrect has wrong size");
  752.         return NULL;
  753.     }
  754.     packed = PyString_FromStringAndSize((char *)NULL, packedcount);
  755.     if (packed == NULL)
  756.         return NULL;
  757.     parray = (unsigned long *) PyString_AsString(unpacked);
  758.     p = (unsigned char *) PyString_AsString(packed);
  759.     for (y = 0; y < height; y += packfactor, parray += packfactor*width) {
  760.         for (x = 0; x < width; x += packfactor) {
  761.             pixel = parray[x];
  762.             r = pixel & 0xff;
  763.             g = (pixel >> 8) & 0xff;
  764.             b = (pixel >> 16) & 0xff;
  765.             *p++ = (30*r+59*g+11*b) / 100;
  766.         }
  767.     }
  768.     return packed;
  769. }
  770.  
  771. % unpackrect
  772.  
  773. static unsigned long unpacktab[256];
  774. static int unpacktab_inited = 0;
  775.  
  776. static PyObject *
  777. gl_unpackrect(self, args)
  778.     PyObject *self;
  779.     PyObject *args;
  780. {
  781.     long width, height, packfactor;
  782.     char *s;
  783.     PyObject *unpacked, *packed;
  784.     int pixcount, packedcount;
  785.     register unsigned char *p;
  786.     register unsigned long *parray;
  787.     if (!unpacktab_inited) {
  788.         register int white;
  789.         for (white = 256; --white >= 0; )
  790.             unpacktab[white] = white * 0x010101L;
  791.         unpacktab_inited++;
  792.     }
  793.     if (!PyArg_GetLong(args, 4, 0, &width))
  794.         return NULL;
  795.     if (!PyArg_GetLong(args, 4, 1, &height))
  796.         return NULL;
  797.     if (!PyArg_GetLong(args, 4, 2, &packfactor))
  798.         return NULL;
  799.     if (!PyArg_GetString(args, 4, 3, &s)) /* For type checking only */
  800.         return NULL;
  801.     if (!PyArg_GetObject(args, 4, 3, &packed))
  802.         return NULL;
  803.     if (width <= 0 || height <= 0 || packfactor <= 0) {
  804.         PyErr_SetString(PyExc_RuntimeError, "packrect args must be > 0");
  805.         return NULL;
  806.     }
  807.     pixcount = width*height;
  808.     packedcount = ((width+packfactor-1)/packfactor) *
  809.         ((height+packfactor-1)/packfactor);
  810.     if (PyString_Size(packed) != packedcount) {
  811.         PyErr_SetString(PyExc_RuntimeError,
  812.                "string arg to unpackrect has wrong size");
  813.         return NULL;
  814.     }
  815.     unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
  816.     if (unpacked == NULL)
  817.         return NULL;
  818.     parray = (unsigned long *) PyString_AsString(unpacked);
  819.     p = (unsigned char *) PyString_AsString(packed);
  820.     if (packfactor == 1 && width*height > 0) {
  821.         /* Just expand bytes to longs */
  822.         register int x = width * height;
  823.         do {
  824.             *parray++ = unpacktab[*p++];
  825.         } while (--x >= 0);
  826.     }
  827.     else {
  828.         register int y;
  829.         for (y = 0; y < height-packfactor+1;
  830.              y += packfactor, parray += packfactor*width) {
  831.             register int x;
  832.             for (x = 0; x < width-packfactor+1; x += packfactor) {
  833.                 register unsigned long pixel = unpacktab[*p++];
  834.                 register int i;
  835.                 for (i = packfactor*width; (i-=width) >= 0;) {
  836.                     register int j;
  837.                     for (j = packfactor; --j >= 0; )
  838.                         parray[i+x+j] = pixel;
  839.                 }
  840.             }
  841.         }
  842.     }
  843.     return unpacked;
  844. }
  845.  
  846. % gversion
  847. static PyObject *
  848. gl_gversion(self, args)
  849.     PyObject *self;
  850.     PyObject *args;
  851. {
  852.     char buf[20];
  853.     gversion(buf);
  854.     return PyString_FromString(buf);
  855. }
  856.  
  857.  
  858. /* void clear - Manual because of clash with termcap */
  859. %clear
  860. static PyObject *
  861. gl_clear(self, args)
  862.     PyObject *self;
  863.     PyObject *args;
  864. {
  865.     __GLclear( );
  866.     Py_INCREF(Py_None);
  867.     return Py_None;
  868. }
  869.  
  870. /* End of manually written stubs */
  871.  
  872. %%
  873.  
  874. long     getshade
  875. if !solaris    void     devport     short s long s
  876. void     rdr2i         long s long s
  877. void    rectfs         short s short s short s short s
  878. void     rects         short s short s short s short s
  879. void     rmv2i         long s long s
  880. void    noport
  881. void    popviewport
  882. void    clearhitcode
  883. void    closeobj
  884. void    cursoff
  885. void    curson
  886. void    doublebuffer
  887. void     finish
  888. void    gconfig
  889. void    ginit
  890. void    greset
  891. void    multimap
  892. void    onemap
  893. void    popattributes
  894. void    popmatrix
  895. void    pushattributes
  896. void    pushmatrix
  897. void    pushviewport
  898. void    qreset
  899. void    RGBmode
  900. void    singlebuffer
  901. void    swapbuffers
  902. void    gsync
  903. void    gflush
  904. void    tpon
  905. void    tpoff
  906. void    clkon
  907. void    clkoff
  908. void    ringbell
  909. #void    callfunc
  910. void    gbegin
  911. void    textinit
  912. void    initnames
  913. void    pclos
  914. void    popname
  915. if !solaris    void    spclos
  916. void    zclear
  917. void    screenspace
  918. void    reshapeviewport
  919. void    winpush
  920. void    winpop
  921. void    foreground
  922. void    endfullscrn
  923. if !solaris    void    endpupmode
  924. void    fullscrn
  925. if !solaris    void    pupmode
  926. void    winconstraints
  927. void    pagecolor     short s
  928. void    textcolor     short s
  929. void     color           short s
  930. void    curveit        short s
  931. void    font        short s
  932. void     linewidth    short s
  933. void    setlinestyle    short s
  934. void    setmap        short s
  935. void    swapinterval    short s
  936. void    writemask    short s
  937. if !solaris    void    textwritemask    short s
  938. void    qdevice        short s
  939. void    unqdevice    short s
  940. void    curvebasis    short s
  941. void    curveprecision    short s
  942. void    loadname    short s
  943. void    passthrough    short s
  944. void    pushname    short s
  945. void    setmonitor    short s
  946. if !solaris    void    setshade    short s
  947. void    setpattern    short s
  948. if !solaris    void    pagewritemask    short s
  949. #
  950. void    callobj        long s
  951. void    delobj        long s
  952. void     editobj        long s
  953. void    makeobj        long s
  954. void    maketag        long s
  955. void    chunksize    long s
  956. void    compactify    long s
  957. void    deltag        long s
  958. void    lsrepeat    long s
  959. void    objinsert    long s
  960. void     objreplace    long s
  961. void    winclose    long s
  962. void    blanktime    long s
  963. void     freepup        long s
  964. # This is not in the library!?
  965. ###void    pupcolor    long s
  966. #
  967. void    backbuffer    long s
  968. void     frontbuffer    long s
  969. if !solaris    void    lsbackup    long s
  970. void    resetls        long s
  971. void    lampon        long s
  972. void    lampoff        long s
  973. void    setbell        long s
  974. void    blankscreen    long s
  975. void     depthcue    long s
  976. void    zbuffer        long s
  977. void    backface    long s
  978. #
  979. void     cmov2i        long s long s
  980. void     draw2i        long s long s
  981. void    move2i        long s long s
  982. void    pnt2i        long s long s
  983. void     patchbasis    long s long s
  984. void     patchprecision    long s long s
  985. void    pdr2i        long s long s
  986. void    pmv2i        long s long s
  987. void    rpdr2i        long s long s
  988. void    rpmv2i        long s long s
  989. void    xfpt2i        long s long s
  990. void    objdelete    long s long s
  991. void    patchcurves    long s long s
  992. void    minsize        long s long s
  993. void     maxsize        long s long s
  994. void    keepaspect    long s long s
  995. void    prefsize    long s long s
  996. void    stepunit    long s long s
  997. void     fudge        long s long s
  998. void     winmove        long s long s
  999. #
  1000. void     attachcursor    short s short s
  1001. void     deflinestyle    short s short s
  1002. void     noise        short s short s
  1003. void     picksize    short s short s
  1004. void     qenter        short s short s
  1005. void     setdepth    short s short s
  1006. void     cmov2s        short s short s
  1007. void     draw2s        short s    short s
  1008. void     move2s        short s short s
  1009. void     pdr2s        short s short s
  1010. void     pmv2s        short s short s
  1011. void     pnt2s        short s short s
  1012. void     rdr2s        short s short s
  1013. void     rmv2s        short s short s
  1014. void     rpdr2s        short s short s
  1015. void     rpmv2s        short s short s
  1016. void     xfpt2s        short s short s
  1017. #
  1018. void cmov2        float s float s
  1019. void draw2        float s float s
  1020. void move2        float s float s
  1021. void pnt2        float s float s
  1022. void pdr2        float s float s
  1023. void pmv2        float s float s
  1024. void rdr2        float s float s
  1025. void rmv2        float s float s
  1026. void rpdr2        float s float s
  1027. void rpmv2        float s float s
  1028. void xfpt2        float s float s
  1029. #
  1030. void loadmatrix        float s[4*4]
  1031. # Really [4][4]
  1032. void multmatrix        float s[4*4]
  1033. # Really [4][4]
  1034. void crv            float s[3*4]
  1035. # Really [4][3]
  1036. void rcrv            float s[4*4]
  1037. # Really [4][4]
  1038. #
  1039. # Methods that have strings.  
  1040. #
  1041. void addtopup        long s char *s long s
  1042. void charstr        char *s
  1043. void getport         char *s
  1044. long strwidth        char *s
  1045. long winopen        char *s
  1046. void wintitle        char *s
  1047. #
  1048. # Methods that have 1 long (# of elements) and an array 
  1049. #
  1050. void polf        long s float s[3*arg1]
  1051. void polf2        long s float s[2*arg1]
  1052. void poly        long s float s[3*arg1]
  1053. void poly2        long s float s[2*arg1]
  1054. void crvn        long s float s[3*arg1]
  1055. void rcrvn        long s float s[4*arg1]
  1056. #
  1057. void polf2i        long s long s[2*arg1]
  1058. void polfi        long s long s[3*arg1]
  1059. void poly2i        long s long s[2*arg1]
  1060. void polyi        long s long s[3*arg1]
  1061. #
  1062. void polf2s        long s short s[2*arg1]
  1063. void polfs        long s short s[3*arg1]
  1064. void polys        long s short s[3*arg1]
  1065. void poly2s        long s short s[2*arg1]
  1066. #
  1067. void defcursor        short s u_short s[128]
  1068. # Is this useful?
  1069. void writepixels    short s u_short s[arg1]
  1070. # Should be unsigned short...
  1071. void defbasis        long s float s[4*4]
  1072. if !solaris    void gewrite        short s short s[arg1]
  1073. #
  1074. void rotate        short s char s
  1075. # This is not in the library!?
  1076. ###void setbutton        short s char s
  1077. void rot        float s char s
  1078. #
  1079. void circfi        long s long s long s
  1080. void circi        long s long s long s
  1081. void cmovi        long s long s long s
  1082. void drawi        long s long s long s
  1083. void movei        long s long s long s
  1084. void pnti         long s long s long s
  1085. void newtag        long s long s long s
  1086. void pdri          long s long s long s
  1087. void pmvi          long s long s long s
  1088. void rdri          long s long s long s
  1089. void rmvi          long s long s long s
  1090. void rpdri         long s long s long s
  1091. void rpmvi         long s long s long s
  1092. void xfpti         long s long s long s
  1093. #
  1094. void circ        float s float s float s
  1095. void circf        float s float s float s
  1096. void cmov        float s float s float s
  1097. void draw        float s float s float s
  1098. void move        float s float s float s
  1099. void pnt        float s float s float s
  1100. void scale        float s float s float s
  1101. void translate        float s float s float s
  1102. void pdr        float s float s float s
  1103. void pmv        float s float s float s
  1104. void rdr        float s float s float s
  1105. void rmv        float s float s float s
  1106. void rpdr        float s float s float s
  1107. void rpmv        float s float s float s
  1108. void xfpt        float s float s float s
  1109. #
  1110. void RGBcolor        short s short s short s
  1111. void RGBwritemask    short s short s short s
  1112. void setcursor        short s short s short s
  1113. void tie        short s short s short s
  1114. void circfs        short s short s short s
  1115. void circs        short s short s short s
  1116. void cmovs        short s short s short s
  1117. void draws        short s short s short s
  1118. void moves        short s short s short s
  1119. void pdrs        short s short s short s
  1120. void pmvs        short s short s short s
  1121. void pnts        short s short s short s
  1122. void rdrs        short s short s short s
  1123. void rmvs        short s short s short s
  1124. void rpdrs        short s short s short s
  1125. void rpmvs        short s short s short s
  1126. void xfpts        short s short s short s
  1127. void curorigin        short s short s short s
  1128. void cyclemap        short s short s short s
  1129. #
  1130. void patch        float s[4*4] float s[4*4] float s[4*4]
  1131. void splf        long s float s[3*arg1] u_short s[arg1]
  1132. void splf2        long s float s[2*arg1] u_short s[arg1]
  1133. void splfi        long s long s[3*arg1] u_short s[arg1]
  1134. void splf2i        long s long s[2*arg1] u_short s[arg1]
  1135. void splfs        long s short s[3*arg1] u_short s[arg1]
  1136. void splf2s        long s short s[2*arg1] u_short s[arg1]
  1137. ###void defpattern        short s short s u_short s[arg2*arg2/16]
  1138. #
  1139. void rpatch        float s[4*4] float s[4*4] float s[4*4] float s[4*4]
  1140. #
  1141. # routines that send 4 floats
  1142. #
  1143. void ortho2        float s float s float s float s
  1144. void rect        float s float s float s float s
  1145. void rectf        float s float s float s float s
  1146. void xfpt4        float s float s float s float s
  1147. #
  1148. void textport        short s short s short s short s
  1149. void mapcolor        short s short s short s short s
  1150. void scrmask        short s short s short s short s
  1151. void setvaluator    short s short s short s short s
  1152. void viewport        short s short s short s short s
  1153. void shaderange        short s short s short s short s
  1154. void xfpt4s        short s short s short s short s
  1155. void rectfi        long s long s long s long s
  1156. void recti        long s long s long s long s
  1157. void xfpt4i        long s long s long s long s
  1158. void prefposition    long s long s long s long s
  1159. #
  1160. void arc        float s float s float s short s short s
  1161. void arcf        float s float s float s short s short s
  1162. void arcfi        long s long s long s short s short s
  1163. void arci        long s long s long s short s short s
  1164. #
  1165. void bbox2        short s short s float s float s float s float s
  1166. void bbox2i        short s short s long s long s long s long s
  1167. void bbox2s        short s short s short s short s short s short s
  1168. void blink        short s short s short s short s short s
  1169. void ortho        float s float s float s float s float s float s
  1170. void window        float s float s float s float s float s float s
  1171. void lookat        float s float s float s float s float s float s short s
  1172. #
  1173. void perspective    short s float s float s float s
  1174. void polarview        float s short s short s short s
  1175. # XXX getichararray not supported
  1176. #void writeRGB        short s char s[arg1] char s[arg1] char s[arg1]
  1177. #
  1178. void arcfs        short s short s short s short s short s
  1179. void arcs        short s short s short s short s short s
  1180. void rectcopy        short s short s short s short s short s short s
  1181. if !solaris    void RGBcursor        short s short s short s short s short s short s short s
  1182. #
  1183. long getbutton        short s
  1184. long getcmmode
  1185. long getlsbackup
  1186. long getresetls
  1187. long getdcm
  1188. long getzbuffer
  1189. long ismex
  1190. long isobj        long s
  1191. long isqueued        short s
  1192. long istag        long s
  1193. #
  1194. long genobj
  1195. long gentag
  1196. long getbuffer
  1197. long getcolor
  1198. long getdisplaymode
  1199. long getfont
  1200. long getheight
  1201. long gethitcode
  1202. long getlstyle
  1203. long getlwidth
  1204. long getmap
  1205. long getplanes
  1206. long getwritemask
  1207. long qtest
  1208. long getlsrepeat
  1209. long getmonitor
  1210. long getopenobj
  1211. long getpattern
  1212. long winget
  1213. long winattach
  1214. long getothermonitor
  1215. long newpup
  1216. #
  1217. long getvaluator    short s
  1218. void winset        long s
  1219. long dopup        long s
  1220. void getdepth        short r short r
  1221. void getcpos        short r short r
  1222. void getsize        long r long r
  1223. void getorigin        long r long r
  1224. void getviewport    short r short r short r short r
  1225. if !solaris    void gettp        short r short r short r short r
  1226. void getgpos        float r float r float r float r
  1227. void winposition    long s long s long s long s
  1228. void gRGBcolor        short r short r short r
  1229. void gRGBmask        short r short r short r
  1230. void getscrmask    short r short r short r short r
  1231. ###void gRGBcursor    short r short r short r short r short r short r short r short r
  1232. void getmcolor        short s short r short r short r
  1233. void mapw        long s short s short s float r float r float r float r float r float r
  1234. void mapw2        long s short s short s float r float r
  1235. ###void defrasterfont    short s short s short s Fontchar s[arg3] short s short s[4*arg5]
  1236. ###long qread        short r
  1237. void getcursor        short r u_short r u_short r long r
  1238. #
  1239. #   For these we receive arrays of stuff
  1240. #
  1241. ###void getdev         long s short s[arg1] short r[arg1]
  1242. #XXX not generated correctly yet
  1243. #void getmatrix        float r[16]
  1244. ###long readpixels        short s short r[retval]
  1245. ###long readRGB        short s char r[retval] char r[retval] char r[retval]
  1246. ###long blkqread        short s short r[arg1]
  1247. #
  1248. #   New 4D routines
  1249. #
  1250. void cmode
  1251. void concave        long s
  1252. void curstype        long s
  1253. void drawmode        long s
  1254. void gammaramp        short s[256] short s[256] short s[256]
  1255. long getbackface
  1256. long getdescender
  1257. long getdrawmode
  1258. long getmmode
  1259. long getsm
  1260. long getvideo        long s
  1261. void imakebackground
  1262. void lmbind        short s short s
  1263. void lmdef        long s long s long s float s[arg3]
  1264. void mmode        long s
  1265. void normal        float s[3]
  1266. void overlay        long s
  1267. void RGBrange        short s short s short s short s short s short s short s short s
  1268. if !solaris    void setvideo         long s long s
  1269. void shademodel        long s
  1270. void underlay        long s
  1271. #
  1272. # New Personal Iris/GT Routines
  1273. #
  1274. void bgnclosedline
  1275. void bgnline
  1276. void bgnpoint
  1277. void bgnpolygon
  1278. void bgnsurface
  1279. void bgntmesh
  1280. void bgntrim
  1281. void endclosedline
  1282. void endline
  1283. void endpoint
  1284. void endpolygon
  1285. void endsurface
  1286. void endtmesh
  1287. void endtrim
  1288. void blendfunction    long s long s
  1289. void c3f        float s[3]
  1290. void c3i        long  s[3]
  1291. void c3s        short s[3]
  1292. void c4f        float s[4]
  1293. void c4i        long  s[4]
  1294. void c4s        short s[4]
  1295. void colorf        float s
  1296. void cpack        long s
  1297. void czclear        long s long s
  1298. void dglclose        long s
  1299. long dglopen        char *s long s
  1300. long getgdesc        long s
  1301. void getnurbsproperty    long s float r
  1302. void glcompat        long s long s
  1303. void iconsize         long s long s
  1304. void icontitle        char *s
  1305. void lRGBrange        short s short s short s short s short s short s long s long s
  1306. void linesmooth        long s
  1307. void lmcolor        long s
  1308. void logicop        long s
  1309. ###long lrectread         short s short s short s short s long r[retval]
  1310. ###void lrectwrite        short s short s short s short s long s[(arg2-arg1+1)*(arg4-arg3+1)]
  1311. ### Now manual, with string last arg
  1312. ###long rectread         short s short s short s short s short r[retval]
  1313. ###void rectwrite        short s short s short s short s short s[(arg2-arg1+1)*(arg4-arg3+1)]
  1314. void lsetdepth        long s long s
  1315. void lshaderange    short s short s long s long s
  1316. void n3f        float s[3]
  1317. void noborder
  1318. void pntsmooth        long s
  1319. void readsource        long s
  1320. void rectzoom        float s float s
  1321. void sbox        float s float s float s float s
  1322. void sboxi        long s long s long s long s
  1323. void sboxs        short s short s short s short s
  1324. void sboxf        float s float s float s float s
  1325. void sboxfi        long s long s long s long s
  1326. void sboxfs        short s short s short s short s
  1327. void setnurbsproperty    long s float s
  1328. void setpup         long s long s long s
  1329. void smoothline        long s
  1330. void subpixel        long s
  1331. void swaptmesh
  1332. long swinopen        long s
  1333. void v2f        float s[2]
  1334. void v2i        long  s[2]
  1335. void v2s        short s[2]
  1336. void v3f        float s[3]
  1337. void v3i        long  s[3]
  1338. void v3s        short s[3]
  1339. void v4f        float s[4]
  1340. void v4i        long  s[4]
  1341. void v4s        short s[4]
  1342. void videocmd        long s
  1343. long windepth        long s
  1344. void wmpack        long s
  1345. void zdraw        long s
  1346. void zfunction        long s
  1347. void zsource        long s
  1348. void zwritemask        long s
  1349. #
  1350. #   uses doubles
  1351. #
  1352. void v2d        double s[2]
  1353. void v3d        double s[3]
  1354. void v4d        double s[4]
  1355. #
  1356. # Why isn't this here?
  1357. #
  1358. void pixmode        long s long s
  1359. #
  1360. # New in IRIX 4.0
  1361. #
  1362. long qgetfd
  1363. void dither        long s
  1364.